{  Statement: http://acmp.ru/?main=task&id_task=263
   Verdict: Accepted
}
uses
    SysUtils, Math;

var
    a,b,c,t:longint;

begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(a,b,c);
if b > c then begin
    t := c;
    c := b;
    b := t;
end;
write(min(c - b - 1, b + a - c - 1));
end.
